package com.lanyou.esb.cook.proxy.auth;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.lanyou.esb.cook.proxy.auth.processor.AcquireAuthProcessor;
import com.lanyou.esb.cook.proxy.auth.processor.VerifyAuthProcessor;
import com.lanyou.esb.cook.proxy.entity.FieldSystem;
import com.lanyou.esb.cook.proxy.entity.Http;
import com.lanyou.esb.cook.proxy.entity.Token;
import com.lanyou.esb.cook.proxy.exception.AuthException;
import com.lanyou.esb.cook.proxy.meta.Environment;

/**
 * 校验调度器
 * 
 * @author Davey.wu
 */
public interface AuthInvocation {

	/**
	 * 获取认证信息
	 * 
	 * @param request
	 *            ：请求
	 * @param content
	 *            ：请求报文
	 * @param http
	 *            ：接口
	 * @return
	 * @throws Exception
	 * @throws AuthException
	 */
	Map<String, Object> getAuthInfo(HttpServletRequest request, String content,
			Http http, Environment environment) throws AuthException, Exception;

	/**
	 * 权限校验入口
	 * 
	 * @param address
	 *            ：请求地址
	 * @param system
	 *            ：系统
	 * @param http
	 *            ：接口
	 * @param callSystemCode
	 *            ：调用方系统编码
	 * @param environment
	 *            ：环境
	 * @param authInfo
	 *            ：校验信息
	 * @return
	 * @throws AuthException
	 * @throws Exception
	 */
	boolean auth(String address, FieldSystem system, Http http,
			String callSystemCode, Environment environment,
			Map<String, Object> authInfo, Token token) throws AuthException,
			Exception;

	/**
	 * 绑定获取校证信息处理器
	 * 
	 * @param processor
	 *            ：处理器
	 */
	public void bindAcquireAuthProcessor(AcquireAuthProcessor processor);

	/**
	 * 解除绑定获取校证信息处理器
	 * 
	 * @param processor
	 *            ：处理器
	 */
	void unbindAcquireAuthProcessor(AcquireAuthProcessor processor);

	/**
	 * 绑定验证权限处理器
	 * 
	 * @param processor
	 *            ：处理器
	 */
	void bindVerifyAuthProcessor(VerifyAuthProcessor processor);

	/**
	 * 解除绑定验证权限处理器
	 * 
	 * @param processor
	 *            ：处理器
	 */
	void unbindVerifyAuthProcessor(VerifyAuthProcessor processor);
}
